package com.lang;

import com.lang.util.FileSize;
import lombok.Getter;
import lombok.Setter;

import java.net.Proxy;
import java.time.Duration;

/**
 * 下载任务的配置信息
 */
@Getter
@Setter
public abstract class DownloadConfig {

    /**
     * 链接
     */
    private String url;
    /**
     * 保存路径
     */
    private String savePath;
    /**
     * 缓冲区大小
     */
    private int bufferSize = FileSize.MB(10L).intValue();
    /**
     * 设置代理
     */
    private Proxy proxy = Proxy.NO_PROXY;
    /**
     * 链接限制时间
     */
//    @JSONField(serializeUsing = DurationJsonSerializeUsing.class, deserializeUsing = DurationJsonDeserializeUsing.class)
    private Duration connnectTime = Duration.ofSeconds(20);
    /**
     * 读取文件流限制时间
     */
//    @JSONField(serializeUsing = DurationJsonSerializeUsing.class, deserializeUsing = DurationJsonDeserializeUsing.class)
    private Duration readTime = Duration.ofMinutes(5);
    /**
     * 是否已完成
     */
    private boolean done = false;
    /**
     * 当相同文件出现时，是否覆盖文件下载
     */
    private boolean overWrite = false;
    /**
     * 本配置文件的路径
     */
    private String configFilePath;
    /**
     * 临时文件夹
     */
    private String tempDir;
}
